# frozen_string_literal: true
require_relative 'boot'

require 'rails'

require 'active_model/railtie'
require 'active_job/railtie'
require 'active_record/railtie'
require 'action_controller/railtie'
require 'action_view/railtie'
require 'action_cable/engine'
require 'action_mailer/railtie'
require 'sprockets/railtie'

Bundler.require(*Rails.groups)

module Oa
  class Application < Rails::Application
    config.time_zone = 'Asia/Shanghai'
    config.i18n.available_locales = [:en, :'zh-CN']
    config.i18n.default_locale = :en

    config.cache_store = :redis_store, {
      host: Settings.redis.host,
      password: Settings.redis.password,
      port: Settings.redis.port,
      db: Settings.redis.cache,
      expires_in: Settings.redis.expires_in
    }

    config.eager_load_paths += Dir[Rails.root.join('lib')]
    config.eager_load_paths += Dir[Rails.root.join('services')]

    config.generators do |g|
      g.helper false
      g.assets false
      g.view_specs false
    end

    config.active_job.queue_adapter = :sidekiq
    config.active_job.queue_name_prefix = Rails.env
    config.active_job.queue_name_delimiter = '_'

    config.action_mailer.perform_caching = false
    config.action_mailer.raise_delivery_errors = false
    config.action_mailer.delivery_method = :smtp
    config.action_mailer.smtp_settings = {
      address: Settings.mailer.address,
      port: Settings.mailer.port,
      user_name: Settings.mailer.user_name,
      password: Settings.mailer.password
    }
  end
end
